home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 22 / PCPP #22.iso / Quake2 / q2source_12_11 / utils3 / qe4 / qfiles.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-11  |  8.6 KB  |  369 lines

  1.  
  2. //
  3. // qfiles.h: quake file formats
  4. // This file must be identical in the quake and utils directories
  5. //
  6.  
  7. /*
  8. ========================================================================
  9.  
  10. .MD2 triangle model file format
  11.  
  12. ========================================================================
  13. */
  14.  
  15. #define IDALIASHEADER        (('2'<<24)+('P'<<16)+('D'<<8)+'I')
  16. #define ALIAS_VERSION    8
  17.  
  18. #define    MAX_TRIANGLES    4096
  19. #define MAX_VERTS        2048
  20. #define MAX_FRAMES        512
  21. #define MAX_MD2SKINS    32
  22. #define    MAX_SKINNAME    64
  23.  
  24. typedef struct
  25. {
  26.     short    s;
  27.     short    t;
  28. } dstvert_t;
  29.  
  30. typedef struct 
  31. {
  32.     short    index_xyz[3];
  33.     short    index_st[3];
  34. } dtriangle_t;
  35.  
  36. typedef struct
  37. {
  38.     byte    v[3];            // scaled byte to fit in frame mins/maxs
  39.     byte    lightnormalindex;
  40. } dtrivertx_t;
  41.  
  42. typedef struct
  43. {
  44.     float        scale[3];    // multiply byte verts by this
  45.     float        translate[3];    // then add this
  46.     char        name[16];    // frame name from grabbing
  47.     dtrivertx_t    verts[1];    // variable sized
  48. } daliasframe_t;
  49.  
  50.  
  51. // the glcmd format:
  52. // a positive integer starts a tristrip command, followed by that many
  53. // vertex structures.
  54. // a negative integer starts a trifan command, followed by -x vertexes
  55. // a zero indicates the end of the command list.
  56. // a vertex consists of a floating point s, a floating point t,
  57. // and an integer vertex index.
  58.  
  59.  
  60. typedef struct
  61. {
  62.     int            ident;
  63.     int            version;
  64.  
  65.     int            skinwidth;
  66.     int            skinheight;
  67.     int            framesize;        // byte size of each frame
  68.  
  69.     int            num_skins;
  70.     int            num_xyz;
  71.     int            num_st;            // greater than num_xyz for seams
  72.     int            num_tris;
  73.     int            num_glcmds;        // dwords in strip/fan command list
  74.     int            num_frames;
  75.  
  76.     int            ofs_skins;        // each skin is a MAX_SKINNAME string
  77.     int            ofs_st;            // byte offset from start for stverts
  78.     int            ofs_tris;        // offset for dtriangles
  79.     int            ofs_frames;        // offset for first frame
  80.     int            ofs_glcmds;    
  81.     int            ofs_end;        // end of file
  82.  
  83. } dmdl_t;
  84.  
  85. /*
  86. ========================================================================
  87.  
  88. .SP2 sprite file format
  89.  
  90. ========================================================================
  91. */
  92.  
  93. #define IDSPRITEHEADER    (('2'<<24)+('S'<<16)+('D'<<8)+'I')
  94.         // little-endian "IDS2"
  95. #define SPRITE_VERSION    2
  96.  
  97. typedef struct
  98. {
  99.     int        width, height;
  100.     int        origin_x, origin_y;        // raster coordinates inside pic
  101.     char    name[MAX_SKINNAME];        // name of pcx file
  102. } dsprframe_t;
  103.  
  104. typedef struct {
  105.     int            ident;
  106.     int            version;
  107.     int            numframes;
  108.     dsprframe_t    frames[1];            // variable sized
  109. } dsprite_t;
  110.  
  111. /*
  112. ==============================================================================
  113.  
  114.   .WAL texture file format
  115.  
  116. ==============================================================================
  117. */
  118.  
  119.  
  120. #define    MIPLEVELS    4
  121. typedef struct miptex_s
  122. {
  123.     char        name[32];
  124.     unsigned    width, height;
  125.     unsigned    offsets[MIPLEVELS];        // four mip maps stored
  126.     char        animname[32];            // next frame in animation chain
  127.     int            flags;
  128.     int            contents;
  129.     int            value;
  130. } miptex_t;
  131.  
  132.  
  133.  
  134. /*
  135. ==============================================================================
  136.  
  137.   .BSP file format
  138.  
  139. ==============================================================================
  140. */
  141.  
  142. #define IDBSPHEADER    (('P'<<24)+('S'<<16)+('B'<<8)+'I')
  143.         // little-endian "IBSP"
  144.  
  145. #define BSPVERSION    36
  146.  
  147.  
  148. // upper design bounds
  149. // leaffaces, leafbrushes, planes, and verts are still bounded by
  150. // 16 bit short limits
  151. #define    MAX_MAP_MODELS        1024
  152. #define    MAX_MAP_BRUSHES        8192
  153. #define    MAX_MAP_ENTITIES    2048
  154. #define    MAX_MAP_ENTSTRING    0x20000
  155. #define    MAX_MAP_TEXINFO        8192
  156.  
  157. #define    MAX_MAP_PLANES        65536
  158. #define    MAX_MAP_NODES        65536
  159. #define    MAX_MAP_BRUSHSIDES    65536
  160. #define    MAX_MAP_LEAFS        65536
  161. #define    MAX_MAP_VERTS        65536
  162. #define    MAX_MAP_FACES        65536
  163. #define    MAX_MAP_LEAFFACES    65536
  164. #define    MAX_MAP_LEAFBRUSHES 65536
  165. #define    MAX_MAP_PORTALS        65536
  166. #define    MAX_MAP_EDGES        128000
  167. #define    MAX_MAP_SURFEDGES    256000
  168. #define    MAX_MAP_LIGHTING    0x200000
  169. #define    MAX_MAP_VISIBILITY    0x100000
  170.  
  171. // key / value pair sizes
  172.  
  173. #define    MAX_KEY        32
  174. #define    MAX_VALUE    1024
  175.  
  176. //=============================================================================
  177.  
  178. typedef struct
  179. {
  180.     int        fileofs, filelen;
  181. } lump_t;
  182.  
  183. #define    LUMP_ENTITIES        0
  184. #define    LUMP_PLANES            1
  185. #define    LUMP_VERTEXES        2
  186. #define    LUMP_VISIBILITY        3
  187. #define    LUMP_NODES            4
  188. #define    LUMP_TEXINFO        5
  189. #define    LUMP_FACES            6
  190. #define    LUMP_LIGHTING        7
  191. #define    LUMP_LEAFS            8
  192. #define    LUMP_LEAFFACES        9
  193. #define    LUMP_LEAFBRUSHES    10
  194. #define    LUMP_EDGES            11
  195. #define    LUMP_SURFEDGES        12
  196. #define    LUMP_MODELS            13
  197. #define    LUMP_BRUSHES        14
  198. #define    LUMP_BRUSHSIDES        15
  199. #define    LUMP_POP            16
  200.  
  201. #define    HEADER_LUMPS        17
  202.  
  203. typedef struct
  204. {
  205.     int            ident;
  206.     int            version;    
  207.     lump_t        lumps[HEADER_LUMPS];
  208. } dheader_t;
  209.  
  210. typedef struct
  211. {
  212.     float        mins[3], maxs[3];
  213.     float        origin[3];        // for sounds or lights
  214.     int            headnode;
  215.     int            firstface, numfaces;    // submodels just draw faces
  216.                                         // without walking the bsp tree
  217. } dmodel_t;
  218.  
  219.  
  220. typedef struct
  221. {
  222.     float    point[3];
  223. } dvertex_t;
  224.  
  225.  
  226. // 0-2 are axial planes
  227. #define    PLANE_X            0
  228. #define    PLANE_Y            1
  229. #define    PLANE_Z            2
  230.  
  231. // 3-5 are non-axial planes snapped to the nearest
  232. #define    PLANE_ANYX        3
  233. #define    PLANE_ANYY        4
  234. #define    PLANE_ANYZ        5
  235.  
  236. // planes (x&~1) and (x&~1)+1 are allways opposites
  237.  
  238. typedef struct
  239. {
  240.     float    normal[3];
  241.     float    dist;
  242.     int        type;        // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
  243. } dplane_t;
  244.  
  245.  
  246. // contents flags are seperate bits
  247. // a given brush can contribute multiple content bits
  248. // multiple brushes can be in a single leaf
  249.  
  250. // lower bits are stronger, and will eat weaker brushes completely
  251. #define    CONTENTS_SOLID            1        // an eye is never valid in a solid
  252. #define    CONTENTS_WINDOW            2        // translucent, but not watery
  253. #define    CONTENTS_AUX            4
  254. #define    CONTENTS_LAVA            8
  255. #define    CONTENTS_SLIME            16
  256. #define    CONTENTS_WATER            32
  257. #define    CONTENTS_MIST            64
  258. #define    LAST_VISIBLE_CONTENTS    64
  259.  
  260. // remaining contents are non-visible, and don't eat brushes
  261. #define    CONTENTS_PLAYERCLIP        0x10000
  262. #define    CONTENTS_MONSTERCLIP    0x20000
  263.  
  264. // currents can be added to any other contents, and may be mixed
  265. #define    CONTENTS_CURRENT_0        0x40000
  266. #define    CONTENTS_CURRENT_90        0x80000
  267. #define    CONTENTS_CURRENT_180    0x100000
  268. #define    CONTENTS_CURRENT_270    0x200000
  269. #define    CONTENTS_CURRENT_UP        0x400000
  270. #define    CONTENTS_CURRENT_DOWN    0x800000
  271.  
  272. #define    CONTENTS_ORIGIN            0x1000000    // removed before bsping an entity
  273.  
  274. #define    CONTENTS_MONSTER        0x2000000    // should never be on a brush, only in game
  275. #define    CONTENTS_DEADMONSTER    0x4000000
  276. #define    CONTENTS_DETAIL            0x8000000    // brushes to be added after vis leafs
  277. #define    CONTENTS_TRANSLUCENT    0x10000000    // auto set if any surface has trans
  278.  
  279.  
  280.  
  281. typedef struct
  282. {
  283.     int            planenum;
  284.     int            children[2];    // negative numbers are -(leafs+1), not nodes
  285.     short        mins[3];        // for frustom culling
  286.     short        maxs[3];
  287.     unsigned short    firstface;
  288.     unsigned short    numfaces;    // counting both sides
  289. } dnode_t;
  290.  
  291.  
  292. typedef struct texinfo_s
  293. {
  294.     float        vecs[2][4];        // [s/t][xyz offset]
  295.     int            flags;            // miptex flags + overrides
  296.     int            value;            // light emission, etc
  297.     char        texture[32];    // texture name (textures/*.wal)
  298.     int            nexttexinfo;    // for animations, -1 = end of chain
  299. } texinfo_t;
  300.  
  301.  
  302. #define    SURF_LIGHT        0x1        // value will hold the light strength
  303.  
  304. #define    SURF_SLICK        0x2        // effects game physics
  305.  
  306. #define    SURF_SKY        0x4        // don't draw, but add to skybox
  307. #define    SURF_WARP        0x8        // turbulent water warp
  308. #define    SURF_TRANS33    0x10
  309. #define    SURF_TRANS66    0x20
  310. #define    SURF_FLOWING    0x40    // scroll towards angle
  311. #define    SURF_NODRAW        0x80    // don't bother referencing the texture
  312.  
  313.  
  314. // note that edge 0 is never used, because negative edge nums are used for
  315. // counterclockwise use of the edge in a face
  316. typedef struct
  317. {
  318.     unsigned short    v[2];        // vertex numbers
  319. } dedge_t;
  320.  
  321. #define    MAXLIGHTMAPS    4
  322. typedef struct
  323. {
  324.     unsigned short    planenum;
  325.     short        side;
  326.  
  327.     int            firstedge;        // we must support > 64k edges
  328.     short        numedges;    
  329.     short        texinfo;
  330.  
  331. // lighting info
  332.     byte        styles[MAXLIGHTMAPS];
  333.     int            lightofs;        // start of [numstyles*surfsize] samples
  334. } dface_t;
  335.  
  336. typedef struct
  337. {
  338.     int            contents;            // OR of all brushes (not needed?)
  339.  
  340.     int            pvsofs;                // -1 = no info
  341.     int            phsofs;                // -1 = no info
  342.  
  343.     short        mins[3];            // for frustum culling
  344.     short        maxs[3];
  345.  
  346.     unsigned short        firstleafface;
  347.     unsigned short        numleaffaces;
  348.  
  349.     unsigned short        firstleafbrush;
  350.     unsigned short        numleafbrushes;
  351. } dleaf_t;
  352.  
  353. typedef struct
  354. {
  355.     unsigned short    planenum;        // facing out of the leaf
  356.     short    texinfo;
  357. } dbrushside_t;
  358.  
  359. typedef struct
  360. {
  361.     int            firstside;
  362.     int            numsides;
  363.     int            contents;
  364. } dbrush_t;
  365.  
  366. #define    ANGLE_UP    -1
  367. #define    ANGLE_DOWN    -2
  368.  
  369.